package com.livelab.util;

/*
 * IMPORTED CLASS FROM DR. LIANG
 */
public class RunResult {

    public String  outForOneRun = "";
    public boolean isCorrect = false;

    public static RunResult gradeOneRun(String studentOutput, String keyOutput, int i, int cpuTime) {
        RunResult runResult = new RunResult();

        String temp = "";
        for(String s: studentOutput.split("#")){
            temp = temp + s + "\n";
        }
        
        String outForOneRun = "<div id=\"boxstyle\" ; style=\"width: 100%; color: white; text-align: left; border-color: blue; margin-left: 0em; margin-right: 0em; margin-top: 0em\">"
                + "<h3 id=\"h3style\" ; style=\"background-color: blue; text-align: left; padding-left: 1em\">"
                + " Run Status from Test Data Set " + (i + 1) + ": " + cpuTime + "ms CPU time used </h3>"
                + " <div style = \"margin-left:1em\"> <font face=\"Courier New\">";
        outForOneRun += "<pre style=\"color: black;\">" + temp + "</pre>";
        outForOneRun += "<br />";

        if (Utility.grade(studentOutput, keyOutput)) {
            outForOneRun += "<span style=\"background-color: #00FF00; color: black;\">Correct result!</span>";
            outForOneRun += "</font> </div> </div>";
            runResult.isCorrect = true;
        } else {
            outForOneRun += "<span style=\"background-color: #FF0000; color: black;\">Incorrect result!</span>";
            outForOneRun += "</font> </div> </div>";

            runResult.isCorrect = false;
        }

        runResult.outForOneRun = outForOneRun;
        return runResult;
    }
}